package com.fenghongzhang.day005;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.ashokvarma.bottomnavigation.TextBadgeItem;

public class MainActivity extends AppCompatActivity {
    private BottomNavigationBar bottomBar;


    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        bottomBar = (BottomNavigationBar) findViewById(R.id.bottom_bar);


        //模式
        bottomBar.setBarBackgroundColor("#999999")
                .setActiveColor("#ff0000")
                .setInActiveColor("#000000")
//                .setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
        .setMode(BottomNavigationBar.MODE_FIXED);


        TextBadgeItem textBadgeItem = new TextBadgeItem();
        textBadgeItem.setTextColor("#009900");
        textBadgeItem.setText("99");
        textBadgeItem.setBorderWidth(2);
        textBadgeItem.setBorderColor("#0000ff");

        //1.添加item
        bottomBar.addItem(new BottomNavigationItem(R.mipmap.home,"首页"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher,"视频").setBadgeItem(textBadgeItem))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher,"我的"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher,"我的1"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher,"我的2"))
                .initialise();

        //2.点击事件
        bottomBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
            @Override
            public void onTabSelected(int position) {
                Log.i(TAG, "onTabSelected: "+position);
            }

            @Override
            public void onTabUnselected(int position) {
                Log.i(TAG, "onTabUnselected: ");
            }

            @Override
            public void onTabReselected(int position) {
                Log.i(TAG, "onTabReselected: ");
            }
        });




    }

}
